home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / ShadingGroupEditorPanel.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  21.9 KB  |  648 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 24, 1997
  22. //  Author:         tbaudel
  23. //
  24. //  Description:
  25. //      This script creates a panel which has the set editor within it.
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. // utilities functions
  35.  
  36. global proc shadingGroupEditorSetColorShaderMode ()
  37. {
  38.     if (! `optionVar -exists ShadingGroupEditorColorAssign`)
  39.         optionVar -intValue ShadingGroupEditorColorAssign 0;
  40.     int $i=`optionVar -q ShadingGroupEditorColorAssign`;
  41.     if ($i) $i=0; else $i=1;
  42.     optionVar -intValue ShadingGroupEditorColorAssign $i;
  43. }
  44.  
  45. proc string[] getDagOrFacetSelection ()
  46. {
  47.     // first get selected dag objects (or rather their transforms)
  48.     string $dag_sel[]=`ls -sl -transforms`;
  49.     // then get the selected facets
  50.     string $f_sel[]=`ls -sl -shapes -type float3`;
  51.     int $i;
  52.     for ($i=0; $i < size($f_sel); $i++) {
  53.         string $buf[2];
  54.         tokenize $f_sel[$i] "." $buf;
  55.         if (size($buf) > 1) {
  56.             string $buf2[2];
  57.             tokenize $buf[1] "[" $buf2;
  58.             if ($buf2[0] == "f") // insert only facets
  59.                 $dag_sel[size($dag_sel)+1] = $f_sel[$i];
  60.         }
  61.     }
  62.     clear $f_sel;
  63.     return $dag_sel;
  64. }
  65.  
  66.  
  67. global proc shadingGroupEditorCreateSet (int $force, string $setEd)
  68. {
  69.     global int $shadingGroupEditorColorAssign;
  70.     string $items[]=`getDagOrFacetSelection`; 
  71.     if (size($items) > 0) {
  72.         string $shader;    
  73.         string $set=`evalEcho "sets -n shadingGroup -em -r true -nss true"`;
  74.         evalEcho ("partition -e -addSet renderPartition " + $set);
  75.         if (`optionVar -q ShadingGroupEditorColorAssign` != 0) {
  76.             // *** should use a default shading node type given by the user...
  77.             $shader=`evalEcho "shadingNode -asShader lambert -n coloredShader"`;
  78.             setAttr ($shader + ".color") -type double3 `rand 1` `rand 1` `rand 1`;
  79.             select -d $shader;
  80.         } else  {
  81.             string $tmp[]=`listConnections initialShadingGroup.surfaceShader`;
  82.             if (size($tmp) > 0) $shader=$tmp[0]; else $shader="";
  83.         }
  84.         if ($shader != "")
  85.             evalEcho ("connectAttr -f " + $shader + ".outColor " 
  86.                                 + $set + ".surfaceShader");
  87.         string $cmd;
  88.         if ($force) $cmd=("sets -e -fe " + $set);
  89.         else {
  90.             $cmd="sets -e -remove initialShadingGroup ";
  91.             for ($i=0; $i<size($items); $i++)
  92.                 $cmd=($cmd + " " + $items[$i]);
  93.             evalEcho $cmd;
  94.             $cmd=("sets -e -include " + $set);
  95.         }
  96.         for ($i=0; $i<size($items); $i++)
  97.             $cmd=($cmd + " " + $items[$i]);
  98.         evalEcho $cmd;
  99.     } else {
  100.         warning "Only geometry objects and polygon facets can be added to shading groups.";    
  101.     }
  102. }
  103.  
  104. global proc shadingGroupEditorAddItems (int $force, string $setEd)
  105. {
  106.     global int $shadingGroupEditorColorAssign;
  107.     string $items[]=`getDagOrFacetSelection`; 
  108.     if (size($items) > 0) {    
  109.         string $set[]=`setEditor -q -hf $setEd`;
  110.         if (size($set) == 1) {
  111.             string $cmd;
  112.             int $i;
  113.             if ($force) 
  114.                 $cmd=("sets -e -fe " + $set[0]);
  115.             else {
  116.                 $cmd="sets -e -remove initialShadingGroup ";
  117.                 for ($i=0; $i<size($items); $i++)
  118.                     $cmd=($cmd + " " + $items[$i]);
  119.                 evalEcho $cmd;
  120.                 $cmd=("sets -e -include " + $set[0]);
  121.             }
  122.             for ($i=0; $i<size($items); $i++)
  123.                 $cmd=($cmd + " " + $items[$i]);
  124.             evalEcho $cmd;
  125.         } else if (size($set) == 0)
  126.             warning "Select the set to add items to.";
  127.         else warning "Items can be added to only one set.";
  128.     } else warning "Only geometry objects or polygon facets can be added to shading groups.";
  129. }
  130.  
  131. global proc shadingGroupEditorRemoveItems (string $setEd)
  132. {
  133.     string $items[]=`getDagOrFacetSelection`;
  134.     if (size($items) !=0) {
  135.         $cmd="sets -e -fe initialShadingGroup ";
  136.         for ($i=0; $i<size($items); $i++)
  137.             $cmd=($cmd + " " + $items[$i]);
  138.         evalEcho $cmd;
  139.     } else warning "One must select geometry objects or polygon facets to return to the initial shading group.";
  140. }
  141.  
  142. global proc shadingGroupEditorDeleteSet (string $setEd)
  143. {
  144.     string $set[]=`setEditor -q -hf $setEd`;
  145.     if (size($set) > 0) {
  146.         string $i;
  147.         for ($i in $set) {
  148.             string $content[]=`sets -q $i`;
  149.             if (size($content) != 0)
  150.                 sets -e -fe "initialShadingGroup" $content;
  151.         }
  152.         // should evalEcho this...
  153.         delete $set;
  154.     } else warning "Select the set(s) to delete.";
  155. }
  156.  
  157. global proc shadingGroupEditorRenameCallback (string $setEd, string $window)
  158. {
  159.     setParent $window;
  160.     string $set[]=`setEditor -q -hf $setEd`;
  161.     if (size($set) == 1) {
  162.         string $res=`textFieldGrp -q -tx wfield`;
  163.         if ($res != "") {
  164.             $res=`evalEcho ("rename " + $set[0] + " " + $res)`;
  165.             text -e -l (" Previous Name: " + $res) wlabel;
  166.             textFieldGrp  -e -tx $res wfield;
  167.         } else warning "Name cannot be empty.";
  168.     } else warning "One and only one set can be renamed at a time.";
  169. }
  170.  
  171. global proc shadingGroupEditorRenameSet (string $setEd)
  172. {
  173.     string $set[]=`setEditor -q -hf $setEd`;
  174.     if (size($set) == 1) {
  175.         string $w =`window -title "Rename Shading Group" shadingRenameTmpWnd`;
  176.         setUITemplate -pushTemplate NONE;
  177.             columnLayout -adj true -rs 4;
  178.             separator -style "none";
  179.             text -l (" Previous Name: " + $set[0]) -align "left" wlabel;
  180.             textFieldGrp -l " New Name:" -tx $set[0] 
  181.                 -cal 1 "left" -cw 1 90 
  182.                 -cc ("shadingGroupEditorRenameCallback " + $setEd + " " + $w) 
  183.                 wfield;
  184.             separator -style "none";
  185.         setUITemplate -popTemplate;
  186.         showWindow $w;
  187.     } else warning "One and only one set can be renamed at a time.";
  188. }
  189.  
  190. // menu functions
  191.  
  192. global proc
  193. buildShadingGroupEditorModeMenu (string $setEd, string $parentMenu)
  194. {
  195.     setParent -menu $parentMenu;
  196.  
  197.     string $editingItem        = ($setEd + "editingItem");
  198.     string $selectNoExpandItem = ($setEd + "selectNoExpandItem");
  199.     string $selectExpandItem   = ($setEd + "selectExpandItem");;
  200.  
  201.     // Check to see if we have to build the menu items
  202.  
  203.     if (`menu -query -numberOfItems $parentMenu` == 0)
  204.     {
  205.         radioMenuItemCollection;
  206.         menuItem -label "Editing" -ecr false
  207.             -ann "Editing Mode: allows viewing and editing shading groups content."
  208.             -radioButton true
  209.             -command ("setEditor -edit -mode editing " + $setEd)
  210.             $editingItem;
  211.         menuItem -label "Select Contents" -ecr false
  212.             -ann "Select Content Mode: select's the shading groups content."
  213.             -radioButton false
  214.             -command ("setEditor -edit -mode selectExpand " + $setEd)
  215.             $selectExpandItem;
  216.         menuItem -label "Select" -ecr false
  217.             -ann "Select Mode: selects the shading groups as a whole."
  218.             -radioButton false
  219.             -command ("setEditor -edit -mode selectNoExpand " + $setEd)
  220.             $selectNoExpandItem;
  221.     }
  222.  
  223.     string $operatingMode = `setEditor -query -mode $setEd`;
  224.     menuItem -edit
  225.         -radioButton ($operatingMode == "editing")
  226.         $editingItem;
  227.     menuItem -edit
  228.         -radioButton ($operatingMode == "selectNoExpand")
  229.         $selectNoExpandItem;
  230.     menuItem -edit
  231.         -radioButton ($operatingMode == "selectExpand")
  232.         $selectExpandItem;
  233. }
  234.  
  235. global proc
  236. buildShadingGroupEditorBookmarksMenu (string $setEd, string $parentMenu)
  237. {
  238.     setParent -menu $parentMenu;
  239.  
  240.     menu -e -deleteAllItems $parentMenu;
  241.  
  242.     menuItem -ecr false -label "Add Bookmark" -command ("setEdBookmarkAddCallback " + $setEd + " later");
  243.     menuItem -optionBox true -label "Add Bookmark Option Box"
  244.         -command ("setEdBookmarkAddCallback " + $setEd + " first");
  245.     menuItem -ecr false -label "Bookmark Editor..." -command ("setEdBookmarkEditor " + $setEd);
  246.     menuItem -divider true;
  247.     
  248.     // Create a menu item for each bookmark
  249.  
  250.     string $bookmarks[] = `setEditor -query -listBookmarks $setEd`;
  251.     string $bookmark;
  252.  
  253.     for ($bookmark in $bookmarks)
  254.     {
  255.         menuItem -ecr false -l $bookmark
  256.             -command ("setEditor -edit -useBookmark " + $bookmark + " " + $setEd);
  257.         menuItem -optionBox true -l ($bookmark + " Option Box")
  258.             -command ("setEdBookmarkRenameMenuCallback " + $setEd + " " + $bookmark);
  259.     }
  260. }
  261.  
  262. global proc
  263. buildShadingGroupEditorOptionsMenu (string $setEd, string $parentMenu)
  264. {
  265.     setParent -menu $parentMenu;
  266.  
  267.     // These should be unique enough names for the widgets for this
  268.     // instance of the set editor
  269.  
  270.     string $autoUpdateItem     = ($setEd + "autoUpdateItem");
  271.     string $autoExpandItem     = ($setEd + "autoExpandItem");
  272.     string $autoScrollItem     = ($setEd + "autoScrollItem");
  273.     string $listByObjectItem   = ($setEd + "listByObject");
  274.     string $listLengthItem     = ($setEd + "listLengthItem");
  275.     
  276.     // Check to see if we have to build the menu items
  277.  
  278.     if (`menu -query -numberOfItems $parentMenu` == 0)
  279.     {
  280.         menuItem -ecr false -cb false 
  281.             -l "Assign Color to New Groups" 
  282.             -ann "Each time a new shading group is created, assign a new random color to allow easy distinction of shading groups."
  283.             -c "shadingGroupEditorSetColorShaderMode"
  284.             renderingSetsAssignItem;
  285.             
  286.         menuItem -divider true;
  287.         
  288.         menuItem -ecr false -label "Auto Update"
  289.             -checkBox 0
  290.             -command ("setEditor -edit -autoUpdate #1 " + $setEd )
  291.             $autoUpdateItem;
  292.         menuItem -ecr false -label "Auto Expand Frames"
  293.             -checkBox 0
  294.             -command ("setEditor -edit -autoExpand #1 " + $setEd)
  295.             $autoExpandItem;
  296.         menuItem -ecr false -label "Auto Scroll to Selection"
  297.             -checkBox 0
  298.             -command ("setEditor -edit -autoScroll #1 " + $setEd)
  299.             $autoScrollItem;
  300.         menuItem -ecr false -label "List by Object"
  301.             -checkBox 0
  302.             -command ("setEditor -edit -groupComponents #1 " + $setEd)
  303.             $listByObjectItem;
  304.     }
  305.  
  306.     // Update the checkbox state for the menu items
  307.     menuItem -edit
  308.         -checkBox `optionVar -q ShadingGroupEditorColorAssign`
  309.         renderingSetsAssignItem;
  310.  
  311.     menuItem -edit
  312.         -checkBox `setEditor -query -autoUpdate $setEd`
  313.         $autoUpdateItem;
  314.     menuItem -edit
  315.         -checkBox `setEditor -query -autoExpand $setEd`
  316.         $autoExpandItem;
  317.     menuItem -edit
  318.         -checkBox `setEditor -query -autoScroll $setEd`
  319.         $autoScrollItem;
  320.     menuItem -edit
  321.         -checkBox `setEditor -query -groupComponents $setEd`
  322.         $listByObjectItem;
  323.  
  324.     // Update the enable/disable state for the menu items
  325.  
  326.     string $operatingMode = `setEditor -query -mode $setEd`;
  327.     if ($operatingMode == "selectExpand" || $operatingMode == "selectNoExpand") {
  328.         menuItem -edit -enable false $autoExpandItem;
  329.         menuItem -edit -enable false $listByObjectItem;
  330.         menuItem -edit -enable false $autoScrollItem;
  331.     } else {
  332.         menuItem -edit -enable true $autoExpandItem;
  333.         menuItem -edit -enable true $listByObjectItem;
  334.         if (`setEditor -query -groupComponents $setEd`)
  335.             menuItem -edit -enable true $autoScrollItem;
  336.         else menuItem -edit -enable false $autoScrollItem;
  337.     }
  338. }
  339.  
  340. global proc
  341. showShadingGroupEditorMenu (int $show, string $menuBarLayout)
  342. {
  343.     if ($show)
  344.         menuBarLayout -e -h 25 $menuBarLayout;
  345.     else
  346.         menuBarLayout -e -h 1 $menuBarLayout;
  347.     optionVar -intValue showSetEditorMenu $show;
  348. }
  349.  
  350. proc ShadingGroupEditorPopupMenu(string $setEd)
  351. //
  352. //  Description:
  353. //      This script creates popup menu items for the set editor.
  354. //
  355. {
  356.     // Define a unique name for the popup menu for this
  357.     // instance of the set editor
  358.     string $menuPopup = ($setEd + "menuPopup");
  359.  
  360.     popupMenu -ctrlModifier false
  361.         -button 3 -aob false -parent $setEd
  362.         $menuPopup;
  363.  
  364.         // These should be unique enough names for the widgets for this
  365.         // instance of the set editor
  366.  
  367.         string $modePopupMenu = ($setEd + "modePopupMenu");
  368.         string $editPopupMenu = ($setEd + "editPopupMenu");
  369.         string $listPopupMenu = ($setEd + "listPopupMenu");
  370.         string $bookmarksPopupMenu = ($setEd + "bookmarksPopupMenu");
  371.         string $optionsPopupMenu = ($setEd + "optionsPopupMenu");
  372.  
  373.         menuItem -label "Mode" -tearOff true -subMenu true $modePopupMenu;
  374.         menuItem -edit -postMenuCommand ("buildShadingGroupEditorModeMenu " + $setEd + " " + $modePopupMenu) $modePopupMenu;
  375.         setParent -menu ..;
  376.  
  377.         menuItem -label "Edit" -tearOff true -subMenu true -aob true $editPopupMenu;
  378.             menuItem -l "Create Shading Group" 
  379.                 -ann "Add selection to a newly created shading group (facets or objects)."
  380.                 -c ("shadingGroupEditorCreateSet 0 " + $setEd);
  381.             menuItem -l "Create Shading Group (force)" 
  382.                 -ann "Add selection to a newly created shading group (facets or objects). Forces assigned item in the new shader."
  383.                 -c ("shadingGroupEditorCreateSet 1 " + $setEd);
  384.             menuItem -d true;    
  385.             menuItem -label "Add Items"
  386.                 -ann "Add selection to the currently selected shading group (facets or objects)."
  387.                 -c ("shadingGroupEditorAddItems 0 " + $setEd);
  388.             menuItem -label "Add Items (force)"
  389.                 -ann "Add selection to the currently selected shading group (facets or objects). Forces assigned item in the new shader."
  390.                 -c ("shadingGroupEditorAddItems 1 " + $setEd);
  391.             
  392.             menuItem -label "Remove Items"
  393.                 -ann "returns selected items (facets or objects) to the initial shading group."
  394.                 -c ("shadingGroupEditorRemoveItems " + $setEd);
  395.  
  396.             menuItem -d true;
  397.         
  398.             menuItem -l "Delete Shading Group"
  399.                 -ann "Delete selected shading groups, returning their content to the initial shading group."
  400.                 -c ("shadingGroupEditorDeleteSet " + $setEd);
  401.             menuItem -l "Rename Shading Group..."
  402.                 -ann "Brings a window allowing renaming the selected shading group."
  403.                 -c ("shadingGroupEditorRenameSet " + $setEd);
  404.             menuItem -l "Shading Group Attributes..." 
  405.                 -ann "Brings the attribute editor for the selected shading group."
  406.                 -c ("string $set[]=`setEditor -q -hf " + $setEd + "`;"
  407.                     + " if (size($set) == 1) { "
  408.                     + " showEditor $set[0];"
  409.                     + " } else warning \"select the set to edit.\" ");
  410.         setParent -menu ..;
  411.  
  412.         menuItem -label "View" -tearOff true -subMenu true $listPopupMenu;
  413.             menuItem -l "Scroll Frames to Selection" -ecr false
  414.                 -c ("setEditor -edit -scrollFrames " + $setEd) scrollItem;
  415.             menuItem -l "Expand All Frames" -ecr false
  416.                 -c ("setEditor -edit -expandFrames " + $setEd) expandItem;
  417.             menuItem -divider true;
  418.  
  419.             menuItem -l "Update Now" -ecr false
  420.                     -c ("setEditor -edit -reload " + $setEd) updateItem;
  421.             menuItem -l "All Shading Groups" -ecr false
  422.                     -c ("setEditor -edit -allSets " + $setEd + ";" 
  423.                        +"setEditor -edit -showRenderSets true " + $setEd + ";"
  424.                        +"setEditor -edit -showNormalSets false " + $setEd + ";"
  425.                        +"setEditor -edit -showDeformerSets false "+ $setEd + ";"
  426.                        +"setEditor -edit -filter \"DefaultShadingGroupsFilter\" " + $setEd +";") 
  427.                     allItem;
  428.         setParent -menu ..;
  429.  
  430.         // Since the bookmark menu is dynamic allowing it to be torn off
  431.         // causes crashes
  432.         menuItem -label "Bookmarks" -tearOff false -subMenu true -aob true $bookmarksPopupMenu;
  433.         menuItem -edit -postMenuCommand ("buildShadingGroupEditorBookmarksMenu " + $setEd + " " + $bookmarksPopupMenu) $bookmarksPopupMenu;
  434.         setParent -menu ..;
  435.  
  436.         menuItem -label "Options" -tearOff true -subMenu true $optionsPopupMenu;
  437.         menuItem -edit -postMenuCommand ("buildShadingGroupEditorOptionsMenu " + $setEd + " " + $optionsPopupMenu) $optionsPopupMenu;
  438.         setParent -menu ..;
  439.  
  440.     setParent -menu ..;
  441. }
  442.  
  443.  
  444. global proc
  445. createShadingGroupEditor (string $whichPanel)
  446. //
  447. //  Description:
  448. //        Define the editors that are used in this panel.  No
  449. //        controls (widgets) are created at this point.
  450. //
  451. {
  452.     // Create a unique name for the editor based on panel name
  453.     string $setEd = ($whichPanel + "ShadingGroupEd");
  454.     setEditor -unParent $setEd;
  455.     // to avoid having a black first shader, reset the rand seed and start rand;
  456.     seed 1; rand 1; rand 1; rand 1;
  457. }
  458.  
  459. global proc
  460. addShadingGroupEditor (string $whichPanel)
  461. //
  462. //  Description:
  463. //        Add the panel to a layout.
  464. //        Parent the editors to that layout and create any other
  465. //        controls (widgets) required.
  466. //
  467. {
  468.     string $setEd = ($whichPanel + "ShadingGroupEd");
  469.     
  470.     waitCursor -state on;
  471.     // Define a unique name for the menu bar for this
  472.     // instance of the set editor
  473.     string $menuBar = ($setEd + "menuBar");
  474.  
  475.     // Define the standard set editing panel
  476.     string $menuBarLayoutName = `scriptedPanel -q -control $whichPanel`;
  477.     string $formLayoutName = `formLayout`;
  478.     
  479.     if (`optionVar -exists showSetEditorMenu`)
  480.         showShadingGroupEditorMenu (`optionVar -query showSetEditorMenu`) $menuBarLayoutName;
  481.  
  482.     // Attach the menus to the menu form
  483.     setParent $menuBarLayoutName;
  484.         // These should be unique enough names for the widgets for this
  485.         // instance of the set editor
  486.         menu -label "Mode" 
  487.             -tearOff true 
  488.             -familyImage "menuIconMode.xpm"
  489.             -postMenuCommandOnce true
  490.             modeMenu;
  491.         menu -edit 
  492.             -postMenuCommand ("buildShadingGroupEditorModeMenu " + $setEd + " " + "modeMenu") 
  493.                 modeMenu;
  494.             setParent -menu ..;
  495.  
  496.         menu -label "Edit" 
  497.             -tearOff true 
  498.             -aob true 
  499.             -familyImage "menuIconEdit.xpm"
  500.             -postMenuCommandOnce true
  501.             editMenu;
  502.             menuItem -l "Create Shading Group" 
  503.                 -ann "Add selection to a newly created shading group (facets or objects)."
  504.                 -c ("shadingGroupEditorCreateSet 0 " + $setEd);
  505.             menuItem -l "Create Shading Group (force)" 
  506.                 -ann "Add selection to a newly created shading group (facets or objects). Forces assigned item in the new shader."
  507.                 -c ("shadingGroupEditorCreateSet 1 " + $setEd);
  508.  
  509.             menuItem -d true;
  510.             
  511.             menuItem -label "Add Items"
  512.                 -ann "Add selection to the currently selected shading group (facets or objects)."
  513.                 -c ("shadingGroupEditorAddItems 0 " + $setEd);
  514.             menuItem -label "Add Items (force)"
  515.                 -ann "Add selection to the currently selected shading group (facets or objects). Forces assigned item in the new shader."
  516.                 -c ("shadingGroupEditorAddItems 1 " + $setEd);
  517.             
  518.             menuItem -label "Remove Items"
  519.                 -ann "returns selected items (facets or objects) to the initial shading group."
  520.                 -c ("shadingGroupEditorRemoveItems " + $setEd);
  521.  
  522.             menuItem -d true;
  523.         
  524.             menuItem -l "Delete Shading Group"
  525.                 -ann "Delete selected shading groups, returning their content to the initial shading group."
  526.                 -c ("shadingGroupEditorDeleteSet " + $setEd);
  527.             menuItem -l "Rename Shading Group..."
  528.                 -ann "Brings a window allowing renaming the selected shading group."
  529.                 -c ("shadingGroupEditorRenameSet " + $setEd);
  530.             menuItem -l "Shading Group Attributes..." 
  531.                 -ann "Brings the attribute editor for the selected shading group."
  532.                 -c ("string $set[]=`setEditor -q -hf " + $setEd + "`;"
  533.                     + " if (size($set) == 1) { "
  534.                     + " showEditor $set[0] ;"
  535.                     + " } else warning \"select the set to edit.\" ");
  536.         
  537.             setParent -menu ..;
  538.  
  539.         menu -label "View" 
  540.             -tearOff true 
  541.             -familyImage "menuIconView.xpm"
  542.             -postMenuCommandOnce true
  543.             viewMenu;
  544.             menuItem -l "Scroll Frames to Selection" -ecr false
  545.                 -c ("setEditor -edit -scrollFrames " + $setEd) scrollItem;
  546.             menuItem -l "Expand All Frames" -ecr false
  547.                 -c ("setEditor -edit -expandFrames " + $setEd) expandItem;
  548.             menuItem -divider true;
  549.             menuItem -l "Update Now" -ecr false
  550.                     -c ("setEditor -edit -reload " + $setEd) updateItem;
  551.             menuItem -l "All Shading Groups" -ecr false
  552.                     -c ("setEditor -edit -allSets " + $setEd + ";" 
  553.                        +"setEditor -edit -showRenderSets true " + $setEd + ";"
  554.                        +"setEditor -edit -showNormalSets false " + $setEd + ";"
  555.                        +"setEditor -edit -showDeformerSets false "+ $setEd + ";"
  556.                        +"setEditor -edit -filter \"DefaultShadingGroupsFilter\" " + $setEd +";") 
  557.                     allItem;
  558.             setParent -menu ..;
  559.  
  560.         // Since the bookmark menu is dynamic allowing it to be torn off
  561.         // causes crashes
  562.         menu -label "Bookmarks" 
  563.             -tearOff false 
  564.             -aob true 
  565.             -familyImage "menuIconBookmarks.xpm"
  566.             bookmarksMenu;
  567.             menu -edit 
  568.                 -pmc ("buildShadingGroupEditorBookmarksMenu " + $setEd + "  bookmarksMenu") 
  569.                 bookmarksMenu;
  570.             setParent -menu ..;
  571.  
  572.         menu -label "Options" 
  573.             -tearOff true 
  574.             -familyImage "menuIconOptions.xpm"
  575.             -postMenuCommandOnce true
  576.             optionsMenu;
  577.         menu -edit -pmc ("buildShadingGroupEditorOptionsMenu " + $setEd + " optionsMenu") 
  578.                 optionsMenu;
  579.         setParent -menu ..;
  580.  
  581.     // Parent the editor to the editor layout
  582.  
  583.     setEditor -edit -parent $formLayoutName $setEd;
  584.     formLayout -edit
  585.         -attachForm $setEd left 0
  586.         -attachForm $setEd right 0
  587.         -attachForm $setEd top 0
  588.         -attachForm $setEd bottom 0
  589.         $formLayoutName;
  590.  
  591.     ShadingGroupEditorPopupMenu $setEd;
  592.         
  593.     setEditor -edit -showRenderSets true $setEd;
  594.     setEditor -edit -showNormalSets false $setEd;
  595.     setEditor -edit -showDeformerSets false $setEd;
  596.     setEditor -edit -filter "DefaultShadingGroupsFilter" $setEd;    
  597.  
  598.     setParent -top;
  599.     waitCursor -state off;
  600. }
  601.  
  602. global proc
  603. removeShadingGroupEditor (string $whichPanel)
  604. //
  605. //  Description:
  606. //        Remove the panel from a layout.
  607. //        Delete controls.
  608. //
  609. {
  610.     string $setEd = ($whichPanel + "ShadingGroupEd");
  611.     if (`setEditor -exists $setEd`)
  612.         setEditor -edit -unParent $setEd;
  613. }
  614.  
  615. global proc
  616. deleteShadingGroupEditor (string $whichPanel)
  617. //
  618. //  Description:
  619. //        This proc will delete the contents of the panel, but not
  620. //        the panel itself.
  621. //
  622. //  Note:
  623. //        We only need to delete editors here.  Other UI will be taken care of
  624. //        by the remove proc.
  625. //
  626. {
  627.     string $setEd = ($whichPanel + "ShadingGroupEd");
  628.     if (`setEditor -exists $setEd`)
  629.         deleteUI -editor $setEd;
  630. }
  631.  
  632. global proc string
  633. saveStateShadingGroupEditor (string $whichPanel)
  634. //
  635. //  Description:
  636. //        This proc returns a string that when executed will restore the
  637. //        current state of the panel elements.
  638. //
  639. {
  640.     string $indent = "\n\t\t\t";
  641.     string $setEd = ($whichPanel + "ShadingGroupEd");
  642.     return (
  643.             $indent + "$editorName = ($panelName+\"ShadingGroupEd\");\n" +
  644.             `setEditor -query -stateString $setEd`
  645.             );
  646. }
  647.  
  648.